package com.sskj.mine;

import android.text.TextUtils;

import com.hjq.toast.ToastUtils;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.mine.bean.ImgHighBean;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.presenter.BasePresenter;
import com.sskj.mine.AddPaymentActivity;

import java.io.File;

import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;


/**
 * @author Hey
 * Create at  2019/05/01
 */
class AddPaymentPresenter extends BasePresenter<AddPaymentActivity> {

    public void submitVerify(File file) {
        OkGo.<HttpData<ImgHighBean>>post(HttpConfig.BASE_URL + HttpConfig.HIGH_VERIFY_IMG)
                .isMultipart(false)
                .params("file_pic", file)
                .execute(new JsonCallBack<HttpData<ImgHighBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<ImgHighBean>> response) {
                        HttpData body = response.body();
                        if (body.status == HttpConfig.OK) {
                            ToastUtil.showShort(body.msg);
                            ImgHighBean hignBean = (ImgHighBean) body.getData();
                            mView.updateUi(hignBean);
                        }
                    }
                });
    }

    // 添加支付方式
    //  ""  支付方式（alipay）
    public void requestAddPayWay(String type, String selectName, String bankBranch, String bankNum, String aliaccount, String imagePath, String payPwd) {

        HttpParams params = new HttpParams();
        params.put("wx_img", imagePath);
        params.put("ali_img", imagePath);
        params.put("act", type);
        params.put("type", selectName);
        params.put("bank", bankBranch);
        params.put("bank_car", bankNum);
        params.put("wx", aliaccount);
        params.put("alipay", aliaccount);
        params.put("pal_account", aliaccount);
        params.put("tpwd", payPwd);
        OkGo.<HttpData<Object>>post(HttpConfig.BASE_URL + HttpConfig.ADD_PAY_PWD)
                .params(params)
                .execute(new JsonCallBack<HttpData<Object>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<Object>> response) {
                        if (response.body().getStatus() == 200) {
                            mView.finish();
                        }
                    }
                });
    }

}
